home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1995 July & August / cd No4 joystick No62.iso / mac / pc / SHARE / LIGHTLIB / LANGUAGE.Z / LLIDVIEW.CPP < prev    next >
C/C++ Source or Header  |  1995-02-22  |  44KB  |  1,318 lines

  1. // LLIDview.cpp : implementation of the CLLIDView class
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6. extern "C"          // include the LightLibImage header file
  7. {
  8. #include "LLI.H"
  9. }
  10.  
  11. #include "LLID.h"
  12. #include "LLIDdoc.h"
  13. #include "LLIDview.h"
  14.  
  15. #include "math.h"
  16.  
  17.  
  18. #ifdef _DEBUG
  19. #undef THIS_FILE
  20. static char BASED_CODE THIS_FILE[] = __FILE__;
  21. #endif
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CLLIDView
  25.  
  26. IMPLEMENT_DYNCREATE(CLLIDView, CScrollView)
  27.  
  28. BEGIN_MESSAGE_MAP(CLLIDView, CScrollView)
  29.  //{{AFX_MSG_MAP(CLLIDView)
  30.     ON_WM_PAINT()
  31.     ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
  32.     ON_WM_LBUTTONDOWN()
  33.     ON_WM_MOUSEMOVE()
  34.     ON_WM_LBUTTONUP()
  35.     ON_COMMAND(ID_FIT_HOR, OnFitHor)
  36.     ON_COMMAND(ID_FIT_WIN, OnFitWin)
  37.     ON_COMMAND(ID_FIT_VER, OnFitVer)
  38.     ON_COMMAND(ID_TOGGLE_PALETTE, OnTogglePalette)
  39.     ON_COMMAND(ID_ROT_R90, OnRotR90)
  40.     ON_COMMAND(ID_ROT_L90, OnRotL90)
  41.     ON_COMMAND(ID_ROT_180, OnRot180)
  42.     ON_WM_SIZE()
  43.     ON_COMMAND(ID_UNFIT_WIN, OnUnfitWin)
  44.     ON_COMMAND(ID_IMAGE_INFO, OnImageInfo)
  45.     ON_COMMAND(ID_ZOOM_IN, OnZoomIn)
  46.     ON_COMMAND(ID_ZOOM_OUT, OnZoomOut)
  47.     ON_COMMAND(ID_CROP, OnCrop)
  48.     //}}AFX_MSG_MAP
  49.  // Standard printing commands
  50.  ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
  51.  ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
  52. END_MESSAGE_MAP()
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CLLIDView construction/destruction
  56.  
  57. CLLIDView::CLLIDView()
  58. {
  59.  // TODO: add construction code here
  60. }
  61.  
  62. CLLIDView::~CLLIDView()
  63. {
  64. }
  65.  
  66. void CLLIDView::OnDraw(CDC* pDC)  // overridden to draw this view
  67. {
  68. }
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CLLIDView printing
  72.  
  73. BOOL CLLIDView::OnPreparePrinting(CPrintInfo* pInfo)
  74. {
  75.  // default preparation
  76.  return DoPreparePrinting(pInfo);
  77. }
  78.  
  79. void CLLIDView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  80. {
  81.  // TODO: add extra initialization before printing
  82. }
  83.  
  84. void CLLIDView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  85. {
  86.  // TODO: add cleanup after printing
  87. }
  88.  
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CLLIDView diagnostics
  91.  
  92. #ifdef _DEBUG
  93. void CLLIDView::AssertValid() const
  94. {
  95.     CScrollView::AssertValid();
  96. }
  97.  
  98. void CLLIDView::Dump(CDumpContext& dc) const
  99. {
  100.     CScrollView::Dump(dc);
  101. }
  102.  
  103. CLLIDDoc* CLLIDView::GetDocument() // non-debug version is inline
  104. {
  105.  ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLLIDDoc)));
  106.  return (CLLIDDoc*)m_pDocument;
  107. }
  108. #endif //_DEBUG
  109.  
  110. /////////////////////////////////////////////////////////////////////////////
  111. // CLLIDView message handlers
  112.  
  113.  
  114. void CLLIDView::OnPaint()
  115. {
  116.     CaptureAll();
  117.  
  118.     CPaintDC dc(this); // device context for painting
  119.     CLLIDDoc* pDoc = GetDocument();
  120.     ASSERT_VALID(pDoc);
  121.  
  122.     // we only paint the visible region of the image
  123.  
  124.     // get the size of the client area used for iPut
  125.     CRect rect;
  126.     GetClientRect( &rect );   
  127.  
  128.     // get the current scrolloffset used for iPut
  129.     CPoint ScrollOffset;
  130.     ScrollOffset = GetScrollPosition();             
  131.     
  132.     if( pDoc->lloImage ) 
  133.     {
  134.         DWORD pal;   
  135.         if ( ExclusivePaletteIsActive ) pal = LLI_PALETTE_EXCLUSIVE;
  136.         else  pal = LLI_PALETTE_SHARED;
  137.         
  138.         iPut( pDoc->lloImage,                 // pointer to the image
  139.               ScrollOffset.x,                 // upper left corner X
  140.               ScrollOffset.y,                 // upper left corner Y
  141.               ScrollOffset.x + rect.Width(),  // lower right corner X
  142.               ScrollOffset.y + rect.Height(), // lower right corner Y
  143.               LLI_SCREEN,                     // destination screen
  144.               LLI_SCREEN_DEVICE_CONTEXT,      // format
  145.               0,                              // horizontal offset on screen
  146.               0,                              // vertical offset on screen
  147.               (DWORD)(dc.m_hDC),              // devicecontext of this view
  148.               pal,                            // palette shared or exclusive
  149.               0,                              // - not used -
  150.               0,                              // - not used -
  151.               0,                              // - not used -
  152.               (DWORD)this );                  // user parameter
  153.     }
  154. }
  155.  
  156. /////////////////////////////////////////////////////////////////////////////////
  157.  
  158. void CLLIDView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
  159. {
  160.     // in case of an update first reset the capture region to the
  161.     // entire size
  162.     CaptureAll();
  163.  
  164.     CScrollView::OnUpdate(pSender, lHint, pHint);
  165. }
  166.  
  167. /////////////////////////////////////////////////////////////////////////////////
  168.  
  169. void CLLIDView::OnInitialUpdate()
  170. {
  171.     // initialize zoom state (100% from size cache)
  172.     m_zoomNum = CSize(100, 100);
  173.     m_zoomDenom = CSize(100, 100);
  174.     
  175.     // we need the imagesize in order to calculate the scrollsizes
  176.     // of our view window.
  177.     CLLIDDoc* pDoc = GetDocument();
  178.     CSize dSize = pDoc->GetImageSize( TRUE );
  179.     SetScrollSizes( MM_TEXT, dSize );
  180.     
  181.     CaptRect.left   = 0;             // and set CaptRect to this size
  182.     CaptRect.top    = 0;
  183.     CaptRect.right  = dSize.cx;
  184.     CaptRect.bottom = dSize.cy;
  185.     CaptureAll();
  186.  
  187.  
  188.     ExclusivePaletteIsActive = FALSE;// for best image quality
  189.     ScaleX = 1; ScaleY = 1;         // initial scale in case of fit mode
  190.  
  191.     // initial zoomfactor for zoom in/out<<<
  192.     ZoomX = -1;
  193.     ZoomY = -1;
  194.     
  195.     rotangle = 0;                   // no rotation at the beginning
  196.     CurrentFitMode = ID_UNFIT_WIN;  // no fit mode at beginning
  197.  
  198.     // call base class last (will call OnUpdate)
  199.     CScrollView::OnInitialUpdate();
  200. }
  201.  
  202. /////////////////////////////////////////////////////////////////////////////////
  203.  
  204. void CLLIDView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
  205. {
  206.     CScrollView::OnPrepareDC(pDC, pInfo);
  207.  
  208.     pDC->SetMapMode(MM_TEXT);
  209.     pDC->SetViewportExt(m_zoomNum);
  210.     pDC->SetWindowExt(m_zoomDenom);
  211. }
  212.  
  213. /////////////////////////////////////////////////////////////////////////////////
  214.  
  215. BOOL CLLIDView::OnScrollBy(CSize sizeScroll, BOOL bDoScroll)
  216. {
  217.     CaptureAll();
  218.     CRect rect;
  219.     GetClientRect( &rect );   
  220.     
  221.     // do the scroll
  222.     if (!CScrollView::OnScrollBy(sizeScroll, bDoScroll))
  223.         return FALSE;
  224.  
  225.     // update the position of the image
  226.     if (bDoScroll)
  227.     {
  228.         UpdateWindow();
  229.     }
  230.     return TRUE;
  231. }
  232.  
  233. /////////////////////////////////////////////////////////////////////////////////
  234.  
  235.  
  236. void CLLIDView::OnFilePrint()
  237. {
  238.     // TODO: Add your command handler code here
  239.     CPaintDC dc(this); // device context for painting
  240.     CLLIDDoc* pDoc = GetDocument();
  241.     ASSERT_VALID(pDoc);
  242.     
  243.     // get the current scrolloffset used for iPut
  244.     CPoint ScrollOffset;
  245.     ScrollOffset = GetScrollPosition();
  246.     
  247.     if( pDoc->lloImage ) 
  248.     {
  249.         if ( CaptureIsVisible ) // print the selectet area only
  250.         {
  251.             iPut(pDoc->lloImage,                  // pointer to the image
  252.                  ScrollOffset.x + CaptRect.left,  // upper left corner X
  253.                  ScrollOffset.y + CaptRect.top,   // upper left corner Y
  254.                  ScrollOffset.x + CaptRect.right, // lower right corner X
  255.                  ScrollOffset.y + CaptRect.bottom,// lower right corner Y
  256.                  LLI_PRINTER,                     // destination printer
  257.                  0,                               // format
  258.                  0,                               // horizontal printeroffset
  259.                  0,                               // vertical printeroffset
  260.                  0,                               // printer port
  261.                  0,                               // density
  262.                  0,                               // ejection
  263.                  0,                               // page format
  264.                  0,                               // - not used -
  265.                  (DWORD)this );                   // userparameter
  266.         }
  267.         else  // print the whole image
  268.         {
  269.             iPut(pDoc->lloImage,                  // pointer to the image
  270.                  0,                               // upper left corner X
  271.                  0,                               // upper left corner Y
  272.                  -1,                              // lower right corner X
  273.                  -1,                              // lower right corner Y
  274.                  LLI_PRINTER,                     // destination printer
  275.                  0,                               // format
  276.                  0,                               // horizontal printeroffset
  277.                  0,                               // vertical printeroffset
  278.                  0,                               // printer port
  279.                  0,                               // density
  280.                  0,                               // ejection
  281.                  0,                               // page format
  282.                  0,                               // - not used -
  283.                  (DWORD)this );                   // userparameter
  284.         }
  285.     }
  286.     
  287. }
  288.  
  289. /////////////////////////////////////////////////////////////////////////////////
  290.  
  291. void CLLIDView::SwapInt(int *v1, int *v2)
  292. {
  293.     int tmp;       // swap two integer values
  294.     tmp = *v1;
  295.     *v1 = *v2;
  296.     *v2 = tmp;
  297. }
  298.  
  299. /////////////////////////////////////////////////////////////////////////////////
  300.  
  301. void CLLIDView::SwapFloat(float *v1, float *v2)
  302. {
  303.     float tmp;       // swap two float values
  304.     tmp = *v1;
  305.     *v1 = *v2;
  306.     *v2 = tmp;
  307. }
  308.  
  309. /////////////////////////////////////////////////////////////////////////////////
  310.  
  311. CRect CLLIDView::GetSelection()
  312. {                   
  313.     // We return the selected region
  314.     CRect Selection;
  315.     CPoint ScrollOffset;
  316.     ScrollOffset = GetScrollPosition();
  317.     
  318.     if ( CaptureIsVisible )
  319.     {
  320.         Selection.left   = ScrollOffset.x + CaptRect.left;
  321.         Selection.top    = ScrollOffset.y + CaptRect.top;
  322.         Selection.right  = ScrollOffset.x + CaptRect.right;
  323.         Selection.bottom = ScrollOffset.y + CaptRect.bottom;
  324.     }
  325.     else return CaptRect;
  326.     
  327.     return Selection;
  328. }
  329.  
  330. /////////////////////////////////////////////////////////////////////////////////
  331.  
  332. void CLLIDView::CaptureAll()
  333. {           
  334.     if ( CaptureIsVisible ) // if the rectangle is allready visible then remove it
  335.     {                       // before drawing the new one
  336.         CDC *dc; 
  337.         dc = GetDC();
  338.         dc->SelectObject( GetStockObject( NULL_BRUSH ) );  // hide the old frame
  339.         dc->SetROP2( R2_NOTMERGEPEN );
  340.         dc->Rectangle( CaptRect );   
  341.         ReleaseDC( dc );
  342.     }
  343.     CaptureIsVisible = FALSE;
  344.     LButtonIsDown = 0;
  345.     CLLIDDoc* pDoc = GetDocument();   // create a pointer to the image
  346.     CSize si;
  347.     si = pDoc->GetImageSize( TRUE ); // get height and width of image
  348.     CaptRect.left   = 0;             // and set CaptRect to this size
  349.     CaptRect.top    = 0;
  350.     CaptRect.right  = si.cx;
  351.     CaptRect.bottom = si.cy;
  352. }
  353.  
  354. /////////////////////////////////////////////////////////////////////////////////
  355.  
  356. void CLLIDView::OnLButtonDown(UINT nFlags, CPoint point)
  357. {
  358.     // TODO: Add your message handler code here and/or call default
  359.  
  360.     CLLIDDoc* pDoc = GetDocument();
  361.     if ( !pDoc->lloImage ) return;
  362.  
  363.     // get height and width of current (not original) image
  364.     CSize si;
  365.     si = pDoc->GetImageSize( FALSE ); 
  366.  
  367.     CPoint ScrollOffset;
  368.     ScrollOffset = GetScrollPosition();
  369.     
  370.     // capture inside picture only
  371.     if ( ( point.x > ( si.cx - ScrollOffset.x ) ) || 
  372.          ( point.y > ( si.cy - ScrollOffset.y ) ) ) return; 
  373.  
  374.     CDC *dc; 
  375.     dc = GetDC();
  376.     
  377.     // if the rectangle is allready visible then remove it
  378.     // before drawing the new one
  379.     if ( CaptureIsVisible )
  380.     {                         
  381.         CaptureAll();
  382.     }         
  383.     
  384.     // Load new cursor and sve the old one                  
  385.     oldCursor = SetCursor( LoadCursor( 0, IDC_CROSS ) );
  386.  
  387.     SetCapture();  // from now get all mouse input until LButtonUp
  388.     
  389.     CaptRect.left   = point.x;   // set CaptRect to the position where
  390.     CaptRect.top    = point.y;   // the user clicked the left mousebutton
  391.     CaptRect.right  = point.x;
  392.     CaptRect.bottom = point.y;
  393.     
  394.     LButtonIsDown = TRUE;        // signal that the left button is pressed
  395.     
  396.     dc->SelectObject( GetStockObject( NULL_BRUSH ) );
  397.     dc->SetROP2( R2_NOTMERGEPEN );
  398.     dc->Rectangle( CaptRect );   
  399.  
  400.     ReleaseDC(dc);
  401.     
  402.     CScrollView::OnLButtonDown(nFlags, point);
  403. }
  404.  
  405. /////////////////////////////////////////////////////////////////////////////////
  406.  
  407. void CLLIDView::OnMouseMove(UINT nFlags, CPoint point)
  408. {
  409.     // TODO: Add your message handler code here and/or call default
  410.  
  411.     CLLIDDoc* pDoc = GetDocument();
  412.     if ( !pDoc->lloImage ) return;
  413.  
  414.     // get height and width of current (not original) image
  415.     CSize si;
  416.     si = pDoc->GetImageSize( FALSE ); 
  417.  
  418.     CPoint ScrollOffset;
  419.     ScrollOffset = GetScrollPosition();                       
  420.  
  421.     
  422.     // don't leave the image area
  423.     if ( point.x < 0 ) point.x = 0;
  424.     if ( point.y < 0 ) point.y = 0;
  425.     if ( ( point.x > ( si.cx - ScrollOffset.x ) ) ) 
  426.         point.x = ( si.cx - ScrollOffset.x );
  427.     if ( ( point.y > ( si.cy - ScrollOffset.y ) ) ) 
  428.         point.y = ( si.cy - ScrollOffset.y );
  429.     
  430.     CDC *dc; 
  431.     dc = GetDC();
  432.  
  433.     if ( LButtonIsDown )
  434.     {
  435.         dc->SelectObject( GetStockObject( NULL_BRUSH ) );
  436.         dc->SetROP2( R2_NOTMERGEPEN );
  437.  
  438.         dc->Rectangle( CaptRect );   
  439.  
  440.         CaptRect.right  = point.x;
  441.         CaptRect.bottom = point.y;
  442.  
  443.         dc->Rectangle( CaptRect );                 
  444.     }                       
  445.  
  446.     ReleaseDC( dc );
  447.                                                                    
  448.     CScrollView::OnMouseMove(nFlags, point);
  449. }        
  450.  
  451. /////////////////////////////////////////////////////////////////////////////////
  452.  
  453. void CLLIDView::OnLButtonUp(UINT nFlags, CPoint point)
  454. {
  455.     // TODO: Add your message handler code here and/or call default
  456.  
  457.     if ( LButtonIsDown )
  458.     {                         
  459.         CLLIDDoc* pDoc = GetDocument();
  460.         if ( !pDoc->lloImage ) return;
  461.  
  462.         // get height and width of current (not original) image
  463.         CSize si;
  464.         si = pDoc->GetImageSize( FALSE );
  465.  
  466.         CPoint ScrollOffset;
  467.         ScrollOffset = GetScrollPosition();
  468.              
  469.         //  only allow positions within the clientrect
  470.         if ( point.x < 0 ) point.x = 0;
  471.         if ( point.y < 0 ) point.y = 0;
  472.         if ( ( point.x > ( si.cx - ScrollOffset.x ) ) ) 
  473.             point.x = ( si.cx - ScrollOffset.x );
  474.         if ( ( point.y > ( si.cy - ScrollOffset.y ) ) ) 
  475.             point.y = ( si.cy - ScrollOffset.y );
  476.         
  477.         CaptRect.right  = point.x;
  478.         CaptRect.bottom = point.y;
  479.         LButtonIsDown = FALSE;
  480.         
  481.         if ( (CaptRect.left != CaptRect.right) ||
  482.              (CaptRect.top != CaptRect.bottom) )
  483.         {
  484.             CaptureIsVisible = TRUE;
  485.         }                           
  486.         else CaptureAll();   // set the capture region to maximum
  487.  
  488.         // retreive old cursor
  489.         SetCursor ( oldCursor );
  490.     }
  491.                                                                  
  492.     ReleaseCapture();
  493.     
  494.     if ( CaptRect.left > CaptRect.right ) 
  495.         SwapInt(&CaptRect.left, &CaptRect.right);
  496.         
  497.     if ( CaptRect.top > CaptRect.bottom ) 
  498.         SwapInt(&CaptRect.top, &CaptRect.bottom);
  499.     
  500.     CScrollView::OnLButtonUp(nFlags, point);
  501. }
  502.  
  503. /////////////////////////////////////////////////////////////////////////////////
  504.  
  505.  
  506.  
  507. void CLLIDView::OnFitHor()
  508. {
  509.     // Fit the image to horizontal size of window
  510.     // This mode is active until another fitmode or unfit is selected
  511.     // When the window size changes, the image will be resized, too.
  512.     Fit ( ID_FIT_HOR );
  513. }
  514.  
  515. /////////////////////////////////////////////////////////////////////////////////
  516.  
  517. void CLLIDView::OnFitVer()
  518. {
  519.     // Fit the image to vertical size of window
  520.     // This mode is active until another fitmode or unfit is selected
  521.     // When the window size changes, the image will be resized, too.
  522.     Fit ( ID_FIT_VER ); 
  523. }
  524.  
  525. /////////////////////////////////////////////////////////////////////////////////
  526.  
  527. void CLLIDView::OnFitWin()
  528. {
  529.     // Fit the image to horizontal and vertical size of window
  530.     // This mode is active until another fitmode or unfit is selected
  531.     // When the window size changes, the image will be resized, too.
  532.     Fit ( ID_FIT_WIN );
  533. }
  534.  
  535. /////////////////////////////////////////////////////////////////////////////////
  536.  
  537. void CLLIDView::OnUnfitWin()
  538. {
  539.     // This function disables any of the fitmodes eventually selected
  540.     // and restores the original image with its original size regardless
  541.     // of the current windos clientrect size.
  542.     Rotate( 0 );
  543.     Fit ( ID_UNFIT_WIN );
  544. }
  545.  
  546. /////////////////////////////////////////////////////////////////////////////////
  547.  
  548. void CLLIDView::Fit( UINT fitmode )
  549. {
  550.     CRect rect;
  551.     GetClientRect( &rect );   
  552.  
  553.     CLLIDDoc* pDoc = GetDocument();
  554.     CSize DocSize = pDoc->GetImageSize( TRUE );
  555.  
  556.     if ( CaptureIsVisible )
  557.     {
  558.         DocSize.cx = CaptRect.Width();
  559.         DocSize.cy = CaptRect.Height();
  560.     }             
  561.     
  562.     float zx,zy;
  563.  
  564.     switch ( fitmode )
  565.     {
  566.         case ID_FIT_VER :
  567.             zy = -( (float)(rect.bottom) / (float)(DocSize.cy) );
  568.             zx = zy;
  569.             break;
  570.             
  571.         case ID_FIT_HOR :
  572.             zx = -( (float)(rect.right) / (float)(DocSize.cx) );
  573.             zy = zx;
  574.             break;
  575.             
  576.         case ID_FIT_WIN :
  577.             zx = -( (float)(rect.right) / (float)(DocSize.cx) );
  578.             zy = -( (float)(rect.bottom) / (float)(DocSize.cy) );
  579.             break;
  580.             
  581.         case ID_UNFIT_WIN :
  582.         default :
  583.             zx = -1;
  584.             zy = -1;
  585.             break;
  586.             
  587.     } // end switch ( fitmode )
  588.  
  589.     ZoomX = zx; // update the current zoomfactors used by Zoom In,Out
  590.     ZoomY = zy;
  591.     
  592.     CurrentFitMode = fitmode;
  593.     
  594.     Zoom( zx, zy, FALSE );
  595. }
  596.  
  597. /////////////////////////////////////////////////////////////////////////////////
  598.  
  599. void CLLIDView::Zoom( float zfX, float zfY, BOOL crop )
  600. {
  601.  
  602.     float NewSizeX =0.0, NewSizeY = 0.0;      
  603.  
  604.     // Load new cursor and sve the old one                  
  605.     oldCursor = SetCursor( LoadCursor( 0, IDC_WAIT ) );
  606.  
  607.     CPaintDC dc(this); // device context for painting
  608.     CLLIDDoc* pDoc = GetDocument();
  609.     ASSERT_VALID(pDoc);
  610.                                
  611.     // get the size of the client area used for iPut
  612.     CRect rect;
  613.     GetClientRect( &rect );   
  614.  
  615.     // get the current scrolloffset used for zooming
  616.     CPoint ScrollOffset;
  617.     ScrollOffset = GetScrollPosition();
  618.  
  619.     CSize DocSize = pDoc->GetImageSize( TRUE );
  620.  
  621.     if ( zfX > 0 ) ScaleX *= zfX;
  622.     else
  623.     {
  624.         if ( zfX < 0 ) ScaleX = (float)fabs( (double)zfX );
  625.         else ScaleX = 1;
  626.     }
  627.  
  628.     if ( zfY > 0 ) ScaleY *= zfY;
  629.     else 
  630.     {
  631.         if ( zfY < 0 ) ScaleY = (float)fabs( (double)zfY );
  632.         else ScaleY = 1;
  633.     }
  634.     
  635.     if( pDoc->lloImage ) 
  636.     {
  637.         if ( crop )
  638.         {
  639.             
  640.                     
  641.         }
  642.         else
  643.         {        
  644.             if ( CaptureIsVisible ) // zoom the selected area only
  645.             {
  646.             
  647.                 NewSizeX = ( ScaleX * CaptRect.Width() );
  648.                 NewSizeY = ( ScaleY * CaptRect.Height() );
  649.             
  650.                 IdleStart(20);
  651.                 pDoc->lloImage = iCopy( pDoc->lloImage, // pointer to the image
  652.                     ScrollOffset.x + CaptRect.left,   // upper left corner X
  653.                     ScrollOffset.y + CaptRect.top,    // upper left corner Y
  654.                     ScrollOffset.x + CaptRect.right,  // lower right corner X
  655.                     ScrollOffset.y + CaptRect.bottom, // lower right corner Y
  656.                     LLI_COPY_ZOOM,                    // transformation mode
  657.                     (int)NewSizeX,                    // new horizontal size 
  658.                     (int)NewSizeY,                    // new vertical size
  659.                     0,                                // not used in this case
  660.                     0,                                // not used in this case
  661.                     0,                                // not used in this case
  662.                     (DWORD)this );                    // userparameter
  663.                 IdleStop();
  664.             }
  665.             else      // zoom the whole image
  666.             {
  667.                 NewSizeX = (ScaleX * DocSize.cx);
  668.                 NewSizeY = (ScaleY * DocSize.cy);
  669.  
  670.                 pDoc->lloImage = iCopy( pDoc->lloOrigImage, // pointer to image
  671.                     0,                                // upper left corner X
  672.                     0,                                // upper left corner Y
  673.                     DocSize.cx,                       // lower right corner X
  674.                     DocSize.cy,                       // lower right corner Y
  675.                     LLI_COPY_ZOOM,                    // transformation mode
  676.                     (int)NewSizeX,                    // new horizontal size
  677.                     (int)NewSizeY,                    // new vertical size
  678.                     0,                                // not used in this case
  679.                     0,                                // not used in this case
  680.                     0,                                // not used in this case
  681.                     (DWORD)this );                    // userparameter
  682.             }                                                       
  683.         }
  684.         
  685.         // update the scrolling size 
  686.         SetScrollSizes( MM_TEXT, pDoc->GetImageSize( FALSE ) ); 
  687.         Invalidate( TRUE );
  688.  
  689.     }    
  690.     // retreive old cursor
  691.     SetCursor ( oldCursor );
  692. }
  693.  
  694. /////////////////////////////////////////////////////////////////////////////////
  695.  
  696. void CLLIDView::OnTogglePalette()
  697. {
  698.     // TODO: Add your command handler code here
  699.  
  700.     
  701.     if ( ExclusivePaletteIsActive )
  702.         ExclusivePaletteIsActive = FALSE;
  703.     else
  704.         ExclusivePaletteIsActive = TRUE;
  705.     
  706.     Invalidate( TRUE );  // now redraw with new palette
  707.     UpdateWindow();
  708. }
  709.  
  710. /////////////////////////////////////////////////////////////////////////////////
  711.  
  712. void CLLIDView::OnRotR90()
  713. {
  714.     // rotate the image 90∞ to the right
  715.     Rotate( 90 );
  716.     SwapFloat( &ScaleX, &ScaleY );
  717.     Fit( CurrentFitMode );
  718. }
  719.  
  720. /////////////////////////////////////////////////////////////////////////////////
  721.  
  722. void CLLIDView::OnRotL90()
  723. {
  724.     // rotate the image 90∞ to the left
  725.     Rotate( -90 );
  726.     SwapFloat( &ScaleX, &ScaleY );     
  727.     Fit( CurrentFitMode );
  728. }
  729.  
  730. ////////////////////////////////////////////////////////////////////////////////
  731.  
  732. void CLLIDView::OnRot180()
  733. {
  734.     // rotate the image 180∞ 
  735.     Rotate( 180 );
  736.     Fit( CurrentFitMode );
  737. }
  738.  
  739. /////////////////////////////////////////////////////////////////////////////////
  740.  
  741. void CLLIDView::Rotate( int angle )
  742. {                     
  743.     // Load new cursor and sve the old one                  
  744.     oldCursor = SetCursor( LoadCursor( 0, IDC_WAIT ) );
  745.  
  746.     CPaintDC dc(this); // device context for painting
  747.     CLLIDDoc* pDoc = GetDocument();
  748.     ASSERT_VALID(pDoc);                
  749.  
  750.     if (angle == 0)
  751.     {
  752.         switch( rotangle )
  753.         {
  754.             case  90: angle = -90;
  755.                       break;  
  756.             case 180: angle = 180;
  757.                       break;  
  758.             case 270: angle =  90;
  759.                       break;  
  760.             default : angle =   0;
  761.                       break;  
  762.         }                      
  763.         rotangle = 0;
  764.     }        
  765.     
  766.     if ( pDoc )
  767.     {
  768.         switch ( angle )
  769.         {
  770.             case 90:
  771.                 rotangle += 90;
  772.                 while (rotangle > 360) rotangle -= 360;
  773.                 IdleStart(20);
  774.                 pDoc->lloOrigImage = iCopy( pDoc->lloOrigImage,// pointer to image
  775.                           0,                // upper left corner X
  776.                           0,                // upper left corner Y
  777.                           -1,               // lower right corner X
  778.                           -1,               // lower right corner Y
  779.                           LLI_COPY_TURN,    // transformation mode
  780.                           LLI_TURN_90,      // rotation direction
  781.                           0,                // not used in this case
  782.                           0,                // not used in this case
  783.                           0,                // not used in this case
  784.                           0,                // not used in this case
  785.                           (DWORD)this );    // userparameter
  786.                 IdleStop();
  787.                 break;
  788.                 
  789.             case 180:
  790.                 rotangle += 180;
  791.                 while (rotangle > 360) rotangle -= 360;
  792.                 IdleStart(20);
  793.                 pDoc->lloOrigImage = iCopy( pDoc->lloOrigImage,// pointer to image
  794.                           0,                // upper left corner X
  795.                           0,                // upper left corner Y
  796.                           -1,               // lower right corner X
  797.                           -1,               // lower right corner Y
  798.                           LLI_COPY_TURN,    // transformation mode
  799.                           LLI_TURN_180,     // rotation direction
  800.                           0,                // not used in this case
  801.                           0,                // not used in this case
  802.                           0,                // not used in this case
  803.                           0,                // not used in this case
  804.                           (DWORD)this );    // userparameter
  805.                 IdleStop();
  806.                 break;
  807.                 
  808.             case -90:
  809.                 rotangle -= 90;
  810.                 while (rotangle < 0) rotangle += 360;
  811.                 IdleStart(20);
  812.                 pDoc->lloOrigImage = iCopy( pDoc->lloOrigImage,// pointer to image
  813.                           0,                // upper left corner X
  814.                           0,                // upper left corner Y
  815.                           -1,               // lower right corner X
  816.                           -1,               // lower right corner Y
  817.                           LLI_COPY_TURN,    // transformation mode
  818.                           LLI_TURN_270,     // rotation direction
  819.                           0,                // not used in this case
  820.                           0,                // not used in this case
  821.                           0,                // not used in this case
  822.                           0,                // not used in this case
  823.                           (DWORD)this );    // userparameter
  824.                 IdleStop();
  825.                 break;
  826.                 
  827.             default :; // do nothing
  828.                 
  829.         } // end of switch
  830.         
  831.         // retreive old cursor
  832.         SetCursor ( oldCursor );
  833.     }
  834. }
  835.  
  836. /////////////////////////////////////////////////////////////////////////////////
  837.  
  838. void CLLIDView::OnSize(UINT nType, int cx, int cy)
  839. {
  840.     
  841.     switch ( CurrentFitMode )
  842.     {
  843.         case ID_FIT_HOR : 
  844.         case ID_FIT_VER : 
  845.         case ID_FIT_WIN : Fit( CurrentFitMode );
  846.                           break;
  847.                           
  848.         case ID_UNFIT_WIN :
  849.                           Zoom( ZoomX, ZoomY, FALSE );
  850.                           break;
  851.         default : ; // do nothing
  852.     }
  853. }
  854.  
  855. /////////////////////////////////////////////////////////////////////////////////
  856.  
  857. void CLLIDView::OnImageInfo()
  858. {
  859.     // TODO: Add your command handler code here
  860.     AfxMessageBox( (LPCSTR)"Option not yet available");
  861.     
  862. }
  863.  
  864. /////////////////////////////////////////////////////////////////////////////////
  865.  
  866. void CLLIDView::OnZoomIn()
  867. {
  868.  
  869.     ZoomX += ((ZoomX/100)*10);
  870.     ZoomY += ((ZoomY/100)*10);
  871.     
  872.     CurrentFitMode = ID_UNFIT_WIN;
  873.  
  874.     Zoom( ZoomX, ZoomY, FALSE );                          
  875.     
  876. }
  877.  
  878. /////////////////////////////////////////////////////////////////////////////////
  879.  
  880. void CLLIDView::OnZoomOut()
  881. {
  882.     
  883.     ZoomX -= ((ZoomX/100)*10);
  884.     ZoomY -= ((ZoomY/100)*10);
  885.  
  886.     CurrentFitMode = ID_UNFIT_WIN;
  887.     
  888.     Zoom( ZoomX, ZoomY, FALSE );                          
  889. }
  890.  
  891. /////////////////////////////////////////////////////////////////////////////////
  892.  
  893. void CLLIDView::OnCrop()
  894. {
  895.  
  896.     CLLIDDoc* pDoc = GetDocument();
  897.     ASSERT_VALID(pDoc);                
  898.     CPoint ScrollOffset;
  899.     ScrollOffset = GetScrollPosition();
  900.  
  901.     IdleStart(20);
  902.     pDoc->lloOrigImage = iCopy( pDoc->lloOrigImage, // pointer to the image
  903.                 (int)((float)(ScrollOffset.x + CaptRect.left) / ScaleX ),   // upper left corner X
  904.                 (int)((float)(ScrollOffset.y + CaptRect.top) / ScaleY ),    // upper left corner Y
  905.                 (int)((float)(ScrollOffset.x + CaptRect.right) / ScaleX ),  // lower right corner X
  906.                 (int)((float)(ScrollOffset.y + CaptRect.bottom) / ScaleY ), // lower right corner Y
  907.                 LLI_COPY_CLONE,                   // transformation mode
  908.                 0,                                // new horizontal size 
  909.                 0,                                // new vertical size
  910.                 0,                                // not used in this case
  911.                 0,                                // not used in this case
  912.                 0,                                // not used in this case
  913.                 (DWORD)this );                    // userparameter
  914.     IdleStop();                           
  915.     pDoc->lloImage = iCopy( pDoc->lloOrigImage, // pointer to the image
  916.                 0,                                // upper left corner X
  917.                 0,                                // upper left corner Y
  918.                 -1,                               // lower right corner X
  919.                 -1,                               // lower right corner Y
  920.                 LLI_COPY_CLONE,                   // transformation mode
  921.                 0,                                // new horizontal size 
  922.                 0,                                // new vertical size
  923.                 0,                                // not used in this case
  924.                 0,                                // not used in this case
  925.                 0,                                // not used in this case
  926.                 0 );                              // userparameter
  927.                     
  928.     CaptureAll();
  929.     Fit( ID_UNFIT_WIN );                
  930.     
  931. }
  932.  
  933. /////////////////////////////////////////////////////////////////////////////////
  934.  
  935. void CLLIDView::IdleStart(int times)
  936. {
  937.     oAssign( lloApp, LLI_APPLICATION_IDLE, (DWORD)OnIdle, times );
  938. }
  939.  
  940. /////////////////////////////////////////////////////////////////////////////////
  941.  
  942. void CLLIDView::IdleStop()
  943. {
  944.     oAssign( lloApp, LLI_APPLICATION_IDLE, (DWORD)0, 0 );
  945. }
  946.  
  947. /////////////////////////////////////////////////////////////////////////////////
  948.  
  949. int EXPORTED OnIdle( DWORD dwType, 
  950.                     LONG  lParam,
  951.                     LLOBJECT pImage,
  952.                     DWORD dwAction,
  953.                     DWORD dwDevice,
  954.                     DWORD dwFormat,
  955.                     DWORD dwUdfParam )
  956. {
  957.      //
  958. //  2nd try works, except the cancelbutton
  959. //
  960. //
  961. //
  962.      //CLLIDView *pView = (CLLIDView *)(dwUdfParam);
  963.   
  964.     static RECT rect, bRect, emptyRect;
  965.  
  966.     char txt[20];
  967.     
  968.     static HWND      hWnd;
  969.     static HDC       hDc;
  970.     static HINSTANCE hInst;
  971.     
  972.     static HBRUSH    BkGndBrush;
  973.     static HBRUSH    BarBrush;
  974.     static HBRUSH    EmptyBarBrush;
  975.     static HBRUSH    oldBrush;
  976.     
  977.     static HPEN      cBkGndPen;
  978.     static HPEN      cBarPen;
  979.     static HPEN      cEmptyBarPen;
  980.     static HPEN      oldPen;             
  981.     
  982.     // static CButton CancelButton;      
  983.     // #define IDB_CANCEL 111
  984.     
  985.     lParam *= 5;
  986.     float slice = (float)(rect.right-10) / 100;
  987.     
  988.     switch (dwType)
  989.     {
  990.         case LLI_IDLE_INIT:
  991.             hInst = AfxGetInstanceHandle();
  992.             
  993.             hWnd = CreateWindow( (LPCSTR)"EDIT",
  994.                                  "working... please wait",
  995.                                  WS_VISIBLE | WS_CAPTION,
  996.                                  200, 200, 250, 150,
  997.                                  NULL ,
  998.                                  NULL,
  999.                                  hInst,
  1000.                                  NULL );           
  1001.                                  
  1002.             ShowWindow( hWnd, SW_SHOW );
  1003.             UpdateWindow( hWnd );
  1004.  
  1005.             GetClientRect( hWnd, &rect );
  1006.             
  1007.             hDc = GetDC( hWnd );
  1008.     
  1009.             emptyRect.left   = rect.left + 4;
  1010.             emptyRect.top    = ((rect.bottom / 10) * 5 ) - 1;
  1011.             emptyRect.right  = rect.right - 4;
  1012.             emptyRect.bottom = ((rect.bottom / 10) * 7) + 1;
  1013.  
  1014.             
  1015.             BkGndBrush = CreateSolidBrush( RGB(255, 255, 255) ); 
  1016.             oldBrush   = (HBRUSH)SelectObject( hDc, BkGndBrush );
  1017.             cBkGndPen  = CreatePen( PS_SOLID, 1, RGB(255, 255, 255) );
  1018.             oldPen     = (HPEN)SelectObject( hDc, cBkGndPen );
  1019.             Rectangle( hDc, rect.left,
  1020.                             rect.top,
  1021.                             rect.right,
  1022.                             rect.bottom);
  1023.  
  1024.             EmptyBarBrush = CreateSolidBrush( RGB(192, 192, 192) ); 
  1025.             SelectObject( hDc, EmptyBarBrush );
  1026.             cEmptyBarPen = CreatePen( PS_SOLID, 1, RGB(0, 0, 0) );
  1027.             SelectObject( hDc, cEmptyBarPen );
  1028.             Rectangle( hDc, emptyRect.left,
  1029.                             emptyRect.top,
  1030.                             emptyRect.right,
  1031.                             emptyRect.bottom);
  1032.  
  1033.             BarBrush = CreateSolidBrush( RGB(0, 0, 255) );
  1034.             SelectObject( hDc, BarBrush );
  1035.             cBarPen = CreatePen( PS_SOLID, 1, RGB(255, 255, 255) );
  1036.             SelectObject( hDc, cBarPen );
  1037.  
  1038. /*
  1039.             CancelButton.Create( "Cancel",              // caption
  1040.                                   WS_CHILD | WS_VISIBLE,// style
  1041.                                   CRect(rect.left+10,   // position and size
  1042.                                         rect.bottom-40, //   -"-
  1043.                                         rect.right-10,  //   -"-
  1044.                                         rect.bottom-10),//   -"-
  1045.                                   (CWnd *) hWnd,        // parent
  1046.                                   IDB_CANCEL);          // ID
  1047.           
  1048. */            
  1049.  
  1050.             break;
  1051.             
  1052.         case LLI_IDLE_IDLE:
  1053.             sprintf( txt, "%3d%% done ", (int)lParam );
  1054.             TextOut( hDc, rect.right / 2 - 30, 20, txt, strlen(txt) );
  1055.  
  1056.             bRect.left   = 5;
  1057.             bRect.top    = (rect.bottom / 10) * 5;
  1058.             bRect.right  = (int)( 5 + (float)lParam * slice );
  1059.             bRect.bottom = (rect.bottom / 10) * 7;
  1060.             
  1061.             Rectangle( hDc, bRect.left,
  1062.                             bRect.top,
  1063.                             bRect.right,
  1064.                             bRect.bottom);
  1065.             break;
  1066.             
  1067.         case LLI_IDLE_EXIT:
  1068.  
  1069.             SelectObject( hDc, oldBrush );
  1070.             SelectObject( hDc, oldPen );      
  1071.                            
  1072.             DeleteObject ( cEmptyBarPen );
  1073.             DeleteObject ( cBarPen );
  1074.             DeleteObject ( cBkGndPen );
  1075.             
  1076.             DeleteObject ( EmptyBarBrush );
  1077.             DeleteObject ( BarBrush );
  1078.             DeleteObject ( BkGndBrush );
  1079.             
  1080.             ReleaseDC( hWnd, hDc );
  1081.             DestroyWindow( hWnd );
  1082.             break;
  1083.             
  1084.         default:; // nothing
  1085.     }
  1086.  
  1087.     return ( TRUE );
  1088.  
  1089.  
  1090. /*
  1091.  
  1092. //<<< 3rd try >>>  
  1093.  
  1094.     CLLIDView *pView = (CLLIDView *)(dwUdfParam);
  1095.   
  1096.     #define IDB_CANCEL      111
  1097.     #define IDW_PERCENT_DLG 112
  1098.  
  1099.     static CWnd PercentDlg;
  1100.     
  1101.     static CRect rect, bRect, emptyRect;
  1102.  
  1103.     char txt[20];
  1104.  
  1105.     static CDC    *dc;   
  1106.     
  1107.     static CBrush *BkGndBrush;
  1108.     static CBrush *BarBrush;
  1109.     static CBrush *EmptyBarBrush;
  1110.     static CBrush *oldBrush;     
  1111.  
  1112.     static CPen   *cBkGndPen;
  1113.     static CPen   *cBarPen;
  1114.     static CPen   *cEmptyBarPen;
  1115.     static CPen   *oldPen;
  1116.     static float slice;
  1117.     static CButton CancelButton;
  1118.     
  1119.     lParam *= 5;
  1120.     
  1121.     switch (dwType)
  1122.     {
  1123.         case LLI_IDLE_INIT:
  1124.             PercentDlg.Create((LPCSTR)"EDIT",
  1125.                       "working... please wait",
  1126.                       WS_VISIBLE | WS_CAPTION,
  1127.                       CRect(200, 200, 250, 150),
  1128.                       (CWnd *)HWND_DESKTOP,   //parent
  1129.                       IDW_PERCENT_DLG,
  1130.                       NULL );
  1131.  
  1132.             PercentDlg.ShowWindow( SW_SHOW );
  1133.             PercentDlg.UpdateWindow();
  1134.             
  1135.             dc = PercentDlg.GetDC();
  1136.             PercentDlg.GetClientRect( &rect );
  1137.             slice = (float)(rect.right-4) / 100;
  1138.     
  1139.             BkGndBrush    = new CBrush();
  1140.             BarBrush      = new CBrush();
  1141.             EmptyBarBrush = new CBrush();
  1142.             
  1143.             cBkGndPen     = new CPen;
  1144.             cBarPen       = new CPen;
  1145.             cEmptyBarPen  = new CPen;
  1146.   
  1147.             emptyRect.left   = rect.left + 1;
  1148.             emptyRect.top    = ((rect.bottom / 10) * 4 ) - 1;
  1149.             emptyRect.right  = rect.right - 1;
  1150.             emptyRect.bottom = ((rect.bottom / 10) * 6) + 1;
  1151.  
  1152.             
  1153.             BkGndBrush->CreateSolidBrush( RGB(255, 255, 255) ); 
  1154.             oldBrush = dc->SelectObject( BkGndBrush );
  1155.             cBkGndPen->CreatePen( PS_SOLID, 1, RGB(255, 255, 255) );
  1156.             oldPen = dc->SelectObject( cBkGndPen );
  1157.             dc->Rectangle( rect );
  1158.  
  1159.             EmptyBarBrush->CreateSolidBrush( RGB(192, 192, 192) ); 
  1160.             dc->SelectObject( EmptyBarBrush );
  1161.             cEmptyBarPen->CreatePen( PS_SOLID, 1, RGB(0, 0, 0) );
  1162.             dc->SelectObject( cEmptyBarPen );
  1163.             dc->Rectangle( emptyRect );
  1164.  
  1165.             BarBrush->CreateSolidBrush( RGB(0, 0, 255) );
  1166.             dc->SelectObject( BarBrush );
  1167.             cBarPen->CreatePen( PS_SOLID, 1, RGB(255, 255, 255) );
  1168.             dc->SelectObject( cBarPen );
  1169.  
  1170.             CancelButton.Create( "Cancel", 
  1171.                                   WS_CHILD | WS_VISIBLE, 
  1172.                                   CRect(rect.left+10,
  1173.                                         rect.bottom-40,
  1174.                                         rect.right-10,
  1175.                                         rect.bottom-10),
  1176.                                   (CWnd *) &PercentDlg,
  1177.                                   IDB_CANCEL);
  1178.             
  1179.             break;
  1180.             
  1181.         case LLI_IDLE_IDLE:
  1182.             sprintf( txt, "%3d%% done ", (int)lParam );
  1183.             dc->TextOut( rect.right / 2 - 30, 0, txt, strlen(txt) );
  1184.  
  1185.             bRect.left   = 2;
  1186.             bRect.top    = (rect.bottom / 10) * 4;
  1187.             bRect.right  = (int)( 2 + (float)lParam * slice );
  1188.             bRect.bottom = (rect.bottom / 10) * 6;
  1189.             
  1190.             dc->Rectangle( bRect );
  1191.             break;
  1192.             
  1193.         case LLI_IDLE_EXIT:
  1194.  
  1195.             dc->SelectObject( oldBrush );
  1196.             dc->SelectObject( oldPen );      
  1197.                            
  1198.             delete ( cEmptyBarPen );
  1199.             delete ( cBarPen );
  1200.             delete ( cBkGndPen );
  1201.             
  1202.             delete ( EmptyBarBrush );
  1203.             delete ( BarBrush );
  1204.             delete ( BkGndBrush );
  1205.             
  1206.             PercentDlg.ReleaseDC( dc );
  1207.             PercentDlg.DestroyWindow();
  1208.             break;
  1209.             
  1210.         default:; // nothing
  1211.     }
  1212.  
  1213.     return ( TRUE );
  1214.  
  1215. */
  1216.  
  1217. /*
  1218. //  <<< this original works !!! >>>
  1219.   
  1220.     CLLIDView *pView = (CLLIDView *)(dwUdfParam);
  1221.   
  1222.     CRect rect, bRect, emptyRect;
  1223.     pView->GetClientRect( &rect );
  1224.  
  1225.     char txt[20];
  1226.  
  1227.     static CDC    *dc;   
  1228.     
  1229.     static CBrush *BkGndBrush;
  1230.     static CBrush *BarBrush;
  1231.     static CBrush *EmptyBarBrush;
  1232.     static CBrush *oldBrush;     
  1233.     
  1234.     static CPen   *cBkGndPen;
  1235.     static CPen   *cBarPen;                
  1236.     static CPen   *cEmptyBarPen;
  1237.     static CPen   *oldPen;
  1238.     
  1239.     lParam *= 5;
  1240.     float slice = (float)(rect.right-4) / 100;
  1241.     
  1242.     switch (dwType)
  1243.     {
  1244.         case LLI_IDLE_INIT:
  1245.                 
  1246.             dc = pView->GetDC();
  1247.     
  1248.             BkGndBrush    = new CBrush();
  1249.             BarBrush      = new CBrush();
  1250.             EmptyBarBrush = new CBrush();
  1251.             
  1252.             cBkGndPen    = new CPen;
  1253.             cBarPen      = new CPen;
  1254.             cEmptyBarPen = new CPen;
  1255.   
  1256.             emptyRect.left   = rect.left + 1;
  1257.             emptyRect.top    = ((rect.bottom / 10) * 4 ) - 1;
  1258.             emptyRect.right  = rect.right - 1;
  1259.             emptyRect.bottom = ((rect.bottom / 10) * 6) + 1;
  1260.  
  1261.             
  1262.             BkGndBrush->CreateSolidBrush( RGB(255, 255, 255) ); 
  1263.             oldBrush = dc->SelectObject( BkGndBrush );
  1264.             cBkGndPen->CreatePen( PS_SOLID, 1, RGB(255, 255, 255) );
  1265.             oldPen = dc->SelectObject( cBkGndPen );
  1266.             dc->Rectangle( rect );
  1267.  
  1268.             EmptyBarBrush->CreateSolidBrush( RGB(192, 192, 192) ); 
  1269.             dc->SelectObject( EmptyBarBrush );
  1270.             cEmptyBarPen->CreatePen( PS_SOLID, 1, RGB(0, 0, 0) );
  1271.             dc->SelectObject( cEmptyBarPen );
  1272.             dc->Rectangle( emptyRect );
  1273.  
  1274.             BarBrush->CreateSolidBrush( RGB(0, 0, 255) );
  1275.             dc->SelectObject( BarBrush );
  1276.             cBarPen->CreatePen( PS_SOLID, 1, RGB(255, 255, 255) );
  1277.             dc->SelectObject( cBarPen );
  1278.             break;
  1279.             
  1280.         case LLI_IDLE_IDLE:
  1281.             sprintf( txt, "%3d%% done ", (int)lParam );
  1282.             dc->TextOut( rect.right / 2 - 30, 0, txt, strlen(txt) );
  1283.  
  1284.             bRect.left   = 2;
  1285.             bRect.top    = (rect.bottom / 10) * 4;
  1286.             bRect.right  = (int)( 2 + (float)lParam * slice );
  1287.             bRect.bottom = (rect.bottom / 10) * 6;
  1288.             
  1289.             dc->Rectangle( bRect );
  1290.             break;
  1291.             
  1292.         case LLI_IDLE_EXIT:
  1293.  
  1294.             dc->SelectObject( oldBrush );
  1295.             dc->SelectObject( oldPen );      
  1296.                            
  1297.             delete ( cEmptyBarPen );
  1298.             delete ( cBarPen );
  1299.             delete ( cBkGndPen );
  1300.             
  1301.             delete ( EmptyBarBrush );
  1302.             delete ( BarBrush );
  1303.             delete ( BkGndBrush );
  1304.             
  1305.             pView->ReleaseDC( dc );
  1306.             break;
  1307.             
  1308.         default:; // nothing
  1309.     }
  1310.  
  1311.     return ( TRUE );
  1312.  
  1313. */
  1314.  
  1315. }
  1316.  
  1317.  
  1318.